package com.ixiaowo.sms.system;

import com.ixiaowo.sms.sms.entity.SmsConf;
import com.ixiaowo.sms.sms.utils.Prop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Created by WeiHong on 2017/6/23.
 */
@Component
public class LoadSysConfig {

    private static final Logger LOGGER = LoggerFactory.getLogger(LoadSysConfig.class);

    @PostConstruct
    private void initSystemConfig() {
        LOGGER.info("初始化系统变量,读取 conf.properties 配置文件开始：");
        Prop prop = new Prop("conf.properties");
        SmsConf.setServerIP(prop.get("sms.serverIP"));
        SmsConf.setServerPort(prop.get("sms.serverPort"));
        SmsConf.setAccountSid(prop.get("sms.accountSid"));
        SmsConf.setAccountToken(prop.get("sms.accountToken"));
        SmsConf.setAppID(prop.get("sms.appID"));
        LOGGER.info("sms.properties: {}",SmsConf.getServerIP());
        LOGGER.info("sms.serverIP: {}",SmsConf.getServerPort());
        LOGGER.info("sms.serverPort: {}",SmsConf.getAccountSid());
        LOGGER.info("sms.accountToken: {}",SmsConf.getAccountToken());
        LOGGER.info("sms.appID: {}",SmsConf.getAppID());
        LOGGER.info("初始化系统变量结束！");
    }
}
